package com.linxz.ui.spraycarview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;

import androidx.annotation.DrawableRes;


public class CarPart extends ICarPart {

    private String sprayId;
    @DrawableRes
    private int sprayRes;
    private String metalId;
    @DrawableRes
    private  int metalRes;
    //所属部位ID
    private String partId;
    private String itemId;

    public CarPart(String partId,int left, int top, int width, int height, String sprayId, int sprayRes, String
        metalId, int metalRes) {
        super(left, top, width, height);
        this.partId =partId;
        this.sprayId = sprayId;
        this.sprayRes = sprayRes;
        this.metalId = metalId;
        this.metalRes = metalRes;
    }



    public void checkSpray(){
        setItemId(sprayId);
    }
    public void checkMetal(){
        setItemId(metalId);
    }
    public void checkNull(){
        setItemId(null);
    }

    public String getSprayId() {
        return sprayId;
    }



    public String getMetalId() {
        return metalId;
    }


    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getPartId() {
        return partId;
    }

    public void setPartId(String partId) {
        this.partId = partId;
    }

    @Override
    public int getRes() {
        if(itemId!=null){
            if(itemId.equals(sprayId)){
                return sprayRes;
            }else if(itemId.equals(metalId)){
                return metalRes;
            }
        }
        return 0;
    }
    @Override
    public boolean isShow() {
        return getRes()!=0;
    }


    public void drawSpray(Context context, Canvas canvas, Paint paint){
        draw(context,canvas,paint,sprayRes);
    }

}